<?php
/**
 * Created by PhpStorm.
 * User: haobin
 * Date: 2016/10/13
 * Time: 11:12
 */
//禁言列表
session_start();
require('../conn.php');
require('../functions.php');
require('admin.php');
$page = $_GET['page'];
if (is_numeric($page) == false) {
    $page = 1;
    $page_1 = 1;
    $min = 0;
    $page_2 = $page + 1;
} else {
    if ($page > 1) {
        $page_2 = $page + 1;
        $min = ($page - 1) * 35;
        $page_1 = $page - 1;
    } else {
        $page_1 = 1;
        $min = 0;
        $page_2 = 2;
    }
}
$max = $page * 35;
$sql = "select * from `user` WHERE `ban` = 1 order by `id` desc limit {$min},{$max}";
if ($_GET['do'] == 'search') {
    $phone = guolv($_GET['phone']);
    if (substr($phone, 0, 1) == '#') {
        $search_id = str_replace('#', '', $phone);
        $sql = "select * from `user` where `id`='{$search_id}' order by `id` desc limit {$min},{$max}";
    } else {
        $sql = "select * from `user` where `phone`='{$phone}' order by `id` desc limit {$min},{$max}";
    }
}
if($_GET['do'] == 'money'){
    $sql = "select * from `user` order by `total` desc limit {$min},{$max}";
}
$row_user = $mysql->query($sql);
?>

<?php include('head.php') ?>
<div class="container-fluid">
    <div class="row-fluid">
        <?php
        include('left.php'); ?>
        <div class="span10">
            <h1 class="page-title">用户管理</h1>

            <div class="well">
                <div id="myTabContent" class="tab-content">
                    <div class="tab-pane active in" id="home">
                        <div class="well">
                            <form class="navbar-search pull-left" action="user.php" method="get">
                                <input type="hidden" name="do" value="search">
                                <input type="text" class="search-query" placeholder="#+id搜索会员" name="phone">
                            </form>
                            <div class="pull-right">
                                <a href="banuser.php" class="btn">首页</a></button>
                                <a href="banuser.php?page=<?php echo $page_1 ?>" class="btn"
                                   style="margin-left:5px;">上一页</a>
                                <a href="banuser.php?page=<?php echo $page_2 ?>" class="btn"
                                   style="margin-left:5px;">下一页</a>
                            </div>
                            <table class="table">
                                <thead>
                                <tr>
                                    <th>#</th>
                                    <th>手机号</th>
                                    <th><a href="?do=money">总积分</a></th>
                                    <th>师傅ID</th>
                                    <th>昵称</th>
                                    <th>状态</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php
                                foreach ($row_user as $user) {
                                    if ($user['ban'] == 0) {
                                        $ban = "<font color='green'>正常</font>";
                                    } else if($user['ban'] == 1){
                                        $ban = "<font color='red'>禁言</font>";
                                    }
                                    print <<<table
        <tr>
          <td><a target="_blank"  href="http://app.weiyouqu.net/weiApp/income.php?id={$user['id']}" title="查看用户明细">{$user['id']}</a></td>
     	  <td>{$user['phone']}</td>
		  <td>{$user['total']}</td>
		  <td>{$user['pid']}</td>
		  <td>{$user['name']}</td>
		  <td>{$ban}</td>
        </tr>
table;
                                } ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div class="tab-pane fade" id="profile">
                    </div>
                </div>

            </div>

        </div>
    </div>


</div>

<footer>
    <hr>

    <p class="pull-right"><!--power by right--></p>


    <p><!--power by --></p>
</footer>


<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="lib/bootstrap/js/bootstrap.js"></script>
</body>
</html>